/**
 * @ClassName LC74
 * @Author ykx
 * @Date 2024/3/28 14:14
 * @Version 1.0
 */
public class LC74 {
    public static void main(String[] args) {
        LC74 lc74 = new LC74();
        System.out.println(lc74.searchMatrix(new int[][]{{1, 3}}, 3));
    }

    public boolean searchMatrix(int[][] matrix, int target) {
        for (int[] ints : matrix) {
            if (ints[0] <= target && ints[ints.length - 1] >= target) {
                int left = 0;
                int right = ints.length - 1;
                while (left <= right) {
                    int mid = left + (right - left) / 2;
                    if (ints[mid] == target) {
                        return true;
                    } else if (ints[mid] > target) {
                        right = mid - 1;
                    } else if (ints[mid] < target) {
                        left = mid + 1;
                    }
                }
            }
        }
        return false;
    }
}
